package br.com.poliwar.view.componentes {
	import br.com.poliwar.Sala;
	import br.com.poliwar.view.componentes.events.ItemSalaEvent;
	import flash.events.MouseEvent;
	import flash.filters.GlowFilter;
	/**
	 * ...
	 * @author Ricardo Teixeira
	 */
	public class ItemSala extends ItemSalaSWC {
		
		private var id:int;
		private var quantidade:int;
		private var nome:String;
		
		private var _sala:Sala;
		
		public function ItemSala(sala:Sala) {
			this._sala = sala;
			
			this.nome = sala.moderador.nome;
			this.id = sala.id;
			this.quantidade = sala.quantidadeUsuario;
			
			this.campoNome.text = "» Sala " + id + ": " + nome;
			this.campoQtd.text = "( " + quantidade + " )";
			
			this.mouseChildren = false;
			this.mouseEnabled = true;
			
			this.addEventListener (MouseEvent.CLICK, onClickItem);
			this.addEventListener (MouseEvent.MOUSE_OVER, onOver);
			this.addEventListener (MouseEvent.MOUSE_OUT, onOut);
		}
		
		private function onOut(e:MouseEvent):void {
			this.filters = [];
		}
		
		private function onOver(e:MouseEvent):void {
			this.filters = [new GlowFilter (0x000099, 1, 10, 10)];
		}
		
		private function onClickItem(e:MouseEvent):void {
			var evento:ItemSalaEvent = new ItemSalaEvent (ItemSalaEvent.CLICK_ITEM, this._sala, true);
			this.dispatchEvent (evento);
		}
		
		public function get sala():Sala { return _sala; }
		
	}

}